package com.github.niefy.modules.sys.controller;

import com.github.niefy.common.utils.FileUtil;
import com.github.niefy.common.utils.R;
import com.github.niefy.config.ProjectConfig;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description:
 * @Company：乙盟信息
 * @Author: jiangheng
 * @Date: 2022/1/23 14:34
 * @Version 1.0
 */
@RestController
@RequestMapping("sys/file")
public class FileController extends AbstractController {
    @PostMapping("/upload")
    public R upload(MultipartFile file){
        if(!file.isEmpty()){
            String url = FileUtil.upload(file, ProjectConfig.getPath());
            return R.ok().put("msg","上传成功").put("path",url);
        }else {
            return R.error("error");
        }
    }
}
